package swag.t;


import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

public class BlobsOfMadness extends Activity implements OnTouchListener{
	static TextView editText1;
	static TextView textView2;
	static TextView textView3;
	static TextView textView4;
	static boolean Correct = true;
	private DrawView myDraw;
	
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        editText1 = (TextView) findViewById(R.id.textView1);
        textView2 = (TextView) findViewById(R.id.textView2);
        textView3 = (TextView) findViewById(R.id.textView3);
        textView4 = (TextView) findViewById(R.id.textView4);
        
        LinearLayout linearLayout1 = (LinearLayout) findViewById(R.id.LinearLayout1);
        myDraw = new DrawView(this);
        
        myDraw.setOnTouchListener(this);
        
        
       
        
        linearLayout1.addView(myDraw);
        
     
      
       
        
        editText1.setText(Integer.toString(myDraw.score));
        textView2.setText("Difficulty " + Integer.toString(myDraw.Difficulty));
        textView3.setText(Integer.toString(myDraw.getBall().getLives()) + " Lives");
        textView4.setText("Level " + Integer.toString(myDraw.level));
        

Bundle bundle1 = getIntent().getExtras();
myDraw.setDifficulty(bundle1.getInt("Difficulty"));
myDraw.setLives(bundle1.getInt("Lives"));

        
    
    
    


    
    
    
    
    
    
    
    
    
    }
    
   
    
    public void onStop(){
    	super.onStop();
    	Log.d("stopped", "blobsofmaddness");
    }
    
    public boolean onTouch(View v, MotionEvent event) {
    	  // TODO Auto-generated method stub
    //	if(Math.abs(event.getY()-myDraw.getBall().getx())<350 && Math.abs(event.getX()-myDraw.getBall().gety())<350){
    	  myDraw.getBall().setX((int)event.getX());
    	  myDraw.getBall().setY((int)event.getY());
   
    	  editText1.setText(Integer.toString(myDraw.score));   
    	  textView2.setText("Difficulty " + Integer.toString(myDraw.Difficulty));
    	  textView3.setText(Integer.toString(myDraw.getBall().getLives()) + " Lives");
    	  textView4.setText("Level " + Integer.toString(myDraw.level));

    	  
    	  
    	  if(myDraw.getBall().getLives()<=0)
        {
        	restartProgram();
     
        }
    	  return true;
    }
    
    public void restartProgram() {
    	Intent intent = new Intent(this,HomeScreen.class);
    	int temp=0;
		this.startActivityForResult(intent,temp);
    }
}
